Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@emotion/styled-base

Package Overview
Dependencies
Maintainers
4
Versions
73
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@emotion/styled-base

base styled API for emotion

  • 10.3.0
  • ten
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
314K
decreased by-61.16%
Maintainers
4
Weekly downloads
 
Created

What is @emotion/styled-base?

@emotion/styled-base is a library for writing CSS styles with JavaScript. It allows you to create styled components with a tagged template literal syntax, providing a powerful and flexible way to style your React components.

What are @emotion/styled-base's main functionalities?

Creating Styled Components

This feature allows you to create styled components using the `styled` function. The example demonstrates how to create a styled button with hover effects.

const Button = styled.button`
  background-color: hotpink;
  color: white;
  padding: 10px;
  border: none;
  border-radius: 5px;
  &:hover {
    background-color: darkmagenta;
  }
`;

Theming

Theming allows you to define a theme object and use it throughout your application. The example shows how to use the `ThemeProvider` to pass a theme to styled components.

import { ThemeProvider } from '@emotion/react';

const theme = {
  colors: {
    primary: 'hotpink',
    secondary: 'darkmagenta'
  }
};

const Button = styled.button`
  background-color: ${props => props.theme.colors.primary};
  color: white;
  padding: 10px;
  border: none;
  border-radius: 5px;
  &:hover {
    background-color: ${props => props.theme.colors.secondary};
  }
`;

const App = () => (
  <ThemeProvider theme={theme}>
    <Button>Click me</Button>
  </ThemeProvider>
);

Dynamic Styling

Dynamic styling allows you to change styles based on props. The example demonstrates how to create a button that changes its background color based on the `primary` prop.

const Button = styled.button`
  background-color: ${props => props.primary ? 'hotpink' : 'gray'};
  color: white;
  padding: 10px;
  border: none;
  border-radius: 5px;
  &:hover {
    background-color: ${props => props.primary ? 'darkmagenta' : 'darkgray'};
  }
`;

const App = () => (
  <div>
    <Button primary>Primary Button</Button>
    <Button>Secondary Button</Button>
  </div>
);

Other packages similar to @emotion/styled-base

FAQs

Package last updated on 26 Nov 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc